<template>
    <div class="index_main">
      <div class="phone_box">
        <div class="header_img">
          <img src="@/static/index_configuration/jtk_index.png" alt />
          <div class="redeem_points">
            <!-- 轮播图 -->
            <div class="all_play" @click="addBanner">
                <div class="all_play_banner_null" v-if="bannerList.length==0">点击添加轮播图</div>
                <div class="all_play_banner" v-if="bannerList.length>0">
                    <el-carousel height="110px" indicator-position="outside" :interval="5000">
                        <el-carousel-item v-for="(item, index) in bannerList" :key="index + 'b'">
                            <img class="banner_img" :src="item.imgUrl" alt />
                        </el-carousel-item>
                    </el-carousel>
                </div>
            </div>
          </div>
        </div>
        <div class="classify">
            <div class="classify_head">
                <div class="zzc_box">
                    <el-button type="primary" icon="el-icon-edit" circle @click="navTypeView"></el-button>
                </div>
                <div class="classify_head_box" :class="changeIndex==index?'classify_head_box_color':''" v-for="(item,index) in classificationInfo" :key="index" @click="changeNav(item,index)">
                    <p class="title" :class="item.status=='1'?'title_none':''">{{item.mainTitle}}</p>
                    <span :class="item.status=='1'?'title_none':''">{{item.subTitle}}</span>
                </div>
            </div>
            <div class="classify_main">
                <div class="zzc_box">
                    <el-button type="primary" icon="el-icon-edit" circle @click="navTypeImgView"></el-button>
                </div>
                <div class="classify_main_box" :class="navTypeImgInfo.imgNum=='5'||navTypeImgInfo.imgNum=='10'?'classify_main_box_five':''" v-for="(item,index) in navTypeImgInfo.skipVOS" :key="index">
                    <img :src="item.imgUrl" alt="">
                    <div class="classify_main_box_txt">{{ item.title }}</div>
                </div>
            </div>
        </div>
        <div class="add_button" @click="addViewVisibleView('add')">添加页面组件</div>
        <div class="view_list">
            <div class="view_list_box" v-for="(item,index) in pageViewLs" :key="index">
                <div class="title">{{item.assemblyName}}</div>
                <el-button type="primary" icon="el-icon-edit" circle @click="addViewVisibleView('edit',item)"></el-button>
                <el-button type="danger" icon="el-icon-delete" circle @click="deleteViewVisibleView(item)"></el-button>
            </div>
        </div>
      </div>
      <!-- 轮播图组件 -->
      <banner-diglog v-if="bannerDiglog" :id="id" :visible.sync="bannerDiglog"
        @success="_handleSuccess" />
      <!-- 导航配置弹窗 -->
      <navTypeDialog v-if="navTypeViewVisible" :id="id" :visible.sync="navTypeViewVisible"
       @success="_handleSuccess"></navTypeDialog>
       <!-- 添加编辑页面组件 -->
       <addViewDialog v-if="addViewVisible" :id="id" :pathType="pathType" :visible.sync="addViewVisible" :info="addViewInfo"
       @success="_handleSuccess"></addViewDialog>
       <!-- 导航图标配置弹窗 -->
       <navTypeImgDialog v-if="navTypeImgVisible" :id="classificationId" :visible.sync="navTypeImgVisible"
       @success="_handleSuccess"></navTypeImgDialog>
    </div>
  </template>
  <script>
  import {
    jtkHomePagebanner,jtkHomePageClassification,jtkHomePageComponentsView,jtkHomePageComponentsViewDelete,
    jtkHomePageSkip
  } from "@/api/incentiveManagement/adConfigNew";
  import bannerDiglog from "../components/jtk_main/bannerDiglog";
  import navTypeDialog from "../components/jtk_main/navTypeDialog";
  import addViewDialog from "../components/jtk_main/addViewDialog";
  import navTypeImgDialog from "../components/jtk_main/navTypeImgDialog";
  export default {
    name: "shopDetail",
    components: {
      bannerDiglog,navTypeDialog,addViewDialog,navTypeImgDialog
    },
    props: {},
    data() {
      return {
        bannerDiglog: false,
        bannerList:[],//轮播图详情
        id: "",
        navTypeViewVisible: false,//导航配置弹窗
        classificationInfo:{},//导航分类详情
        addViewVisible: false,//页面组件弹窗
        changeIndex: 0,
        classificationId:'',//分类导航ID
        pathType:'add',
        pageViewLs:{},//页面组件列表
        addViewInfo:{},//页面组件对象
        navTypeImgVisible: false,//导航图片配置弹窗
        navTypeImgInfo: {},//导航图片配置详情
      };
    },
    watch: {},
    created() {
        this.getBanner()
        this.getJtkHomePageClassification()
        this.getJtkHomePageComponentsView()
    },
    mounted() { },
    methods: {
      //获取轮播图
      getBanner() {
        var data = {}
        jtkHomePagebanner(data).then(res => {
            this.bannerList = res.result
        })
      },
      //获取导航分类
      getJtkHomePageClassification(){
        jtkHomePageClassification().then((res) => {
          this.classificationInfo = res.result
          this.classificationId = res.result[0].id
          this.changeIndex = 0
          this.getJtkHomePageSkip()
        })
      },
      //导航分类配置弹窗
      navTypeView(){
        this.navTypeViewVisible = true
      },
      
      //获取页面组件列表
      getJtkHomePageComponentsView(){
        jtkHomePageComponentsView().then((res) => {
          this.pageViewLs = res.result
        })
      },
      //页面组件弹窗
      addViewVisibleView(pathType,item){
        this.pathType = pathType
        if(item!=undefined&&item!=''){
            this.addViewInfo = item
        }
        this.addViewVisible = true
      },
      //删除页面组件
      deleteViewVisibleView(item){
        this.$confirm('是否确认移除' + item.assemblyName, '提示', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
            jtkHomePageComponentsViewDelete(item.id).then((res) => {
            this.getJtkHomePageComponentsView()
            this.$message.success('操作成功');
        })
        }).catch(() => {});
        
      },
      //导航配置弹窗
      navTypeImgView(){
        this.navTypeImgVisible = true
      },
      changeNav(item,index){
        this.classificationId = item.id
        this.changeIndex = index
        this.getJtkHomePageSkip()
      },
      //获取导航图片配置
      getJtkHomePageSkip(){
        var data = {
          classificationId: this.classificationId
        }
        jtkHomePageSkip(data).then(res => {
          this.navTypeImgInfo = res.result
        })
      },
      //添加轮播图
      addBanner() {
        this.bannerDiglog = true;
      },
      _handleSuccess(){
        this.getBanner()
        this.getJtkHomePageClassification()
        this.getJtkHomePageComponentsView()
        // this.getJtkHomePageSkip()
      },
    },
  };
  </script>
  <style lang="scss" scoped>
  .phone_box {
    width: 395px;
    min-height: 800px;
    border-radius: 30px;
    border: 10px solid #333;
    margin: 40px 200px 0 100px;
    background: #f5f8fe;
    box-sizing: border-box;
    overflow: hidden;
  }
  
  .header_img {
    width: 100%;
    height: 284px;
    background: linear-gradient(159.06deg, #FFF6F5 15.98%, #F8D2BA 86.16%);
    position: relative;
    .search_box{
        width: 120px;
        height: 30px;
        cursor: pointer;
        position: absolute;
        top: 50px;
        right: 130px;
        border-radius: 20px;
    }
    .search_box:hover{
        background-color: rgba(0, 0, 0, 0.6);
    }
    img {
      width: 100%;
    }
  }
  .wallet_nav{
    width: 100%;
  }
  .redeem_points{
    position: relative;
    // border-radius: 8px;
    width: 100%;
    height: 140px;
    box-sizing: border-box;
    cursor: pointer;
  }
  .all_play {
    cursor: pointer;
    .all_play_nav {
      width: 100%;
      display: flex;
      align-items: center;
      overflow-x: hidden;
      white-space: nowrap;
      position: absolute;
      top: 46px;
      padding: 0 10px;
      box-sizing: border-box;
  
      .all_play_nav_box {
        height: 20px;
        border-radius: 100px;
        background: #ffffff;
        color: #333333;
        font-size: 12px;
        line-height: 20px;
        padding: 0 10px;
        margin-right: 20px;
      }
    }
    .all_play_banner_null{
      background-color:#eee;
      width: 345px;
      height: 100px;
      color: red;
      display: flex;
      align-items: center;
      justify-content: center;
      margin: 0px auto 0;
      border-radius: 6px;
    }
    .all_play_banner {
      padding: 0px 14px 0;
      position: relative;
      border-radius: 16px;
  
      .all_play_banner_title {
        color: #FFFFFF;
        font-size: 15px;
        position: absolute;
        top: 8px;
      }
  
      .banner_img {
        object-fit: cover;
        height: 104px;
      }
  
      .all_play_banner_name {
        font-size: 15px;
        color: #ffffff;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        position: absolute;
        top: 190px;
        line-height: 24px;
        padding: 0 10px;
      }
  
      .box_detail_address {
        display: flex;
        align-items: center;
        padding-left: 20px;
        position: absolute;
        bottom: 6px;
        z-index: 2;
      }
  
      .box_detail_address_box {
        display: flex;
        align-items: center;
        font-size: 12px;
        color: #ffffff;
        margin-right: 32px;
      }
  
      .box_detail_address_box img {
        width: 16px;
        height: 16px;
        margin-right: 6px;
        margin-bottom: 2px;
      }
    }
  }
  .preview_box_txt{
    width: 36px;
    text-align: center;
    text-align: center;
    font-size: 12px;
    color: #2C2A2F;
    white-space: nowrap;
	  overflow: hidden;
	  text-overflow: ellipsis;
    word-break: break-all;
  }
  .classify{
    background-color: #FFFFFF;
    border-radius: 6px;
    margin: 20px auto;
    width: 345px;
    .classify_head{
        display: flex;
        background-color: #FFFFFF;
        border-radius: 6px 6px 0 0;
        position: relative;
        cursor: pointer;
        min-height: 55px;
        .zzc_box{
          width: 115px;
          height: 100%;
          border-radius: 8px;
          background: rgba(0, 0, 0, 0.6);
          position: absolute;
          top: 0;
          right: 0;
          z-index: 2;
          display: none;
          justify-content: center;
          align-items: center;
      }
    }
    
    .classify_head:hover .zzc_box{
        display: flex;
    }
    .classify_head_box{
        padding: 10px 0;
        font-size: 11px;
        width: calc(100% / 3);
        display: flex;
        flex-direction: column;
        align-items: center;
        word-break: break-all;
        .title{
            text-align: center;
            font-size: 14px;
            font-weight: bold;
            margin-bottom: 6px;
            white-space: nowrap;
		        overflow: hidden;
		        text-overflow: ellipsis;
            width: 100%;
        }
        .title_none{
          color: #ccc;
        }
    }
    .classify_head_box_color{
      background-color: #F8D2BA;
      border-radius: 6px;
    }
    .classify_main{
        min-height: 100px;
        display: flex;
        flex-wrap: wrap;
        padding: 20px 0 2px;
        cursor: pointer;
        position: relative;
        .zzc_box{
            width: 345px;
            height: 100%;
            border-radius: 8px;
            background: rgba(0, 0, 0, 0.6);
            position: absolute;
            top: 0;
            left: 0;
            z-index: 2;
            display: none;
            justify-content: center;
            align-items: center;
        }
        .classify_main_box{
            width: 25%;
            display: flex;
            flex-direction: column;
            align-items: center;
            margin-bottom: 20px;
            .classify_main_box_txt{
              font-size: 13px;
              color: #2C2A2F;
              width: 100%;
              word-break: break-all;
              white-space: nowrap;
		          overflow: hidden;
		          text-overflow: ellipsis;
              text-align: center;
            }
        }
        .classify_main_box_five{
          width: 20%;
        }
        .classify_main_box img{
            width: 36px;
            height: 36px;
            border-radius: 50%;
            margin-bottom: 10px;
            object-fit: cover;
        }
    }
    .classify_main:hover .zzc_box{
        display: flex;
      }
  }
  .add_button{
    width: 345px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    background-color: #1890ff;
    color: #FFFFFF;
    margin: 0 auto;
    cursor: pointer;
    font-size: 14px;
   }
   .add_button:hover{
    opacity: 0.8;
   }
   .view_list{
    width: 345px;
    margin: 20px auto;
    background-color: #FFFFFF;
    border-radius: 6px;
    padding: 10px 10px 2px;
    .view_list_box{
        width: 100%;
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 10px;
    }
    .title{
        flex: 1;
        white-space: nowrap;
		overflow: hidden;
		text-overflow: ellipsis;
    }
   }
  </style>
  